﻿using Application.Roles.Commands.RoleWrite;
using Azure.Core;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Shared.Http.APIResult;

namespace WebApi.Controllers
{
    [Route("api/v1/[controller]/[action]")]
    public class RoleServiceController : ControllerBase
    {
        private readonly IMediator _mediator;

        public RoleServiceController(IMediator mediator)
        {
            _mediator = mediator;
        }

        [HttpPost]
        public async Task<ActionResult> AddRole(RoleWriteCommand request, CancellationToken ct = default)
        {
            var id = await _mediator.Send(request, ct);
            if(id is null)
                return NotFound();//TODO

            return Ok(ApiResult.Success(id, Guid.NewGuid().ToString()));
        }
    }
}
